import 'package:hive/hive.dart';

part 'book.g.dart';

@HiveType(typeId: 1)
class Book {
  @HiveField(0)
  String? wenkuId;

  @HiveField(1)
  String code;

  @HiveField(2)
  String? name;

  @HiveField(3)
  String? titleJp;

  @HiveField(4)
  String? author;

  @HiveField(5)
  String? introductionJp;

  @HiveField(6)
  String? introduction;

  @HiveField(7)
  int? reading;

  @HiveField(8)
  int? initTime;

  Book({
    this.wenkuId,
    required this.code,
    this.name,
    this.titleJp,
    this.author,
    this.introductionJp,
    this.introduction,
    this.reading = 0,
    this.initTime,
  });

  @override
  String toString() {
    return '$name';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Book && runtimeType == other.runtimeType && code == other.code;

  @override
  int get hashCode => code.hashCode;
}
